<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<div class="col-md-12">
    <div class="panel-search">
        <form class="form-inline" action="/orders/nurseIndexInitList">
            <div class="form-group">
                <%--1、等待确认，2、今日预约，3、等待检查，4、全部预约--%>
                <label id="statusIdZero"
                       style="height: 50px;width: 100px;text-align:  center;line-height: 50px;color: black;background-color:pink;">
                    今日预约(<label id="indexTypeToday"></label>)
                </label>
                <label id="statusIdOne"
                       style="height: 50px;width: 100px;text-align:  center;line-height: 50px;color: black;background-color:pink;">
                    等待确认(<label id="indexTypeConfirm"></label>)
                </label>
                <label id="statusIdThree"
                       style="height: 50px;width: 100px;text-align:  center;line-height: 50px;color: black;background-color:pink;">
                    等待检查(<label id="indexTypeCheck"></label>)
                </label>
                <label id="statusIdSix"
                       style="height: 50px;width: 100px;text-align:  center;line-height: 50px;color: black;background-color:pink;">
                    全部预约(<label id="indexTypeAll"></label>)
                </label>
            </div>
        </form>
        <div class="btn-div">
            <div class="div-left">
                待确定预约
            </div>
            <div class="div-right">
                <button type="button" class="btn btn-info" onclick="reset()">
                    <i class="fa fa-repeat"></i> 刷新
                </button>
            </div>
        </div>
    </div>
    <div class="panel-content"></div>
    <div class="panel-show"></div>
</div>
<script type="text/javascript" src="<c:url value="/static/custom/datepicker-util.js"></c:url>"></script>
<script type="text/javascript">
    $(function () {
        search();
        queryStatistics();
    });

    /**
     * 查询科室的统计信息
     */
    function queryStatistics(){
        $.ajax({
            type: 'post',
            url: '<c:url value="/orders/queryIndexStatistics"></c:url>',
            data: null,
            dataType: 'json',
            success: function (data) {
                if(!checkResultCode(data.code)){
                    alert(data.message);
                }else {
                    //今日预约
                    $("#indexTypeToday").text(data.data.indexTypeToday);
                    //等待确认
                    $("#indexTypeConfirm").text(data.data.indexTypeConfirm);
                    //等待检查
                    $("#indexTypeCheck").text(data.data.indexTypeCheck);
                    //全部预约
                    $("#indexTypeAll").text(data.data.indexTypeAll);
                }
            }
        });
    }

    //确认订单
    function comfirmOrder(orderId) {
        $.ajax({
            type: 'post',
            url: '<c:url value="/orders/comfirmOrder"></c:url>',
            data: {id: orderId},
            dataType: 'json',
            success: function (data) {
                if(200 == data.code){
                    search();
                    queryStatistics();
                }else{
                    alert(data.message);
                }
            }
        });
    }
</script>